QT       += core gui widgets serialport network qml quick quickwidgets multimedia multimediawidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = imx6ull_desktop_app
TEMPLATE = app

# C++11标准
CONFIG += c++11

# 禁用QML缓存编译器（避免交叉编译问题）
CONFIG -= qtquickcompiler

# 定义输出目录
CONFIG(debug, debug|release) {
    DESTDIR = $$PWD/build/debug
    OBJECTS_DIR = $$PWD/build/debug/obj
    MOC_DIR = $$PWD/build/debug/moc
    RCC_DIR = $$PWD/build/debug/rcc
    UI_DIR = $$PWD/build/debug/ui
} else {
    DESTDIR = $$PWD/build/release
    OBJECTS_DIR = $$PWD/build/release/obj
    MOC_DIR = $$PWD/build/release/moc
    RCC_DIR = $$PWD/build/release/rcc
    UI_DIR = $$PWD/build/release/ui
}

# 包含路径
INCLUDEPATH += $$PWD/src

# 源文件
SOURCES += \
    src/main.cpp \
    src/mainwindow.cpp \
    src/ui/serial/serialwidget.cpp \
    src/ui/mqtt/mqttwidget.cpp \
    src/ui/common/simplekeyboard.cpp \
    src/ui/common/splashscreen.cpp \
    src/ui/video/videoplayerwidget.cpp \
    src/ui/video/playersettingsdialog.cpp \
    src/ui/video/transcodeprogressdialog.cpp \
    src/business/serial/serialmanager.cpp \
    src/business/mqtt/mqttmanager.cpp \
    src/business/video/videotranscoder.cpp \
    src/models/videoplayermodel.cpp

# 头文件
HEADERS += \
    src/mainwindow.h \
    src/ui/serial/serialwidget.h \
    src/ui/mqtt/mqttwidget.h \
    src/ui/common/simplekeyboard.h \
    src/ui/common/splashscreen.h \
    src/ui/video/videoplayerwidget.h \
    src/ui/video/playersettingsdialog.h \
    src/ui/video/transcodeprogressdialog.h \
    src/business/serial/serialmanager.h \
    src/business/mqtt/mqttmanager.h \
    src/business/video/videotranscoder.h \
    src/models/serialconfig.h \
    src/models/mqttconfig.h \
    src/models/videoplayermodel.h

# 资源文件
RESOURCES += \
    resources/resources.qrc

# 编译器优化 (根据平台自动选择)
CONFIG(release, debug|release) {
    # 基础优化选项(通用)
    QMAKE_CXXFLAGS += -O2
    
    # ARM平台特定优化
    contains(QT_ARCH, arm) {
        QMAKE_CXXFLAGS += -march=armv7-a -mfpu=neon
        message("Building for ARM platform with NEON optimization")
    }
    
    # x86/x64平台优化
    contains(QT_ARCH, i386)|contains(QT_ARCH, x86_64) {
        QMAKE_CXXFLAGS += -msse2
        message("Building for x86/x64 platform")
    }
}

# ARM嵌入式平台配置 (IMX6ULL无GPU支持)
contains(QT_ARCH, arm) {
    # 禁用OpenGL相关特性
    DEFINES += QT_NO_OPENGL
    # 使用软件渲染
    DEFINES += QT_QUICK_SOFTWARE_RENDERER
    # 禁用图形特效以提升性能
    DEFINES += QT_NO_GRAPHICSEFFECT
    message("ARM platform detected: OpenGL disabled, using software renderer")
}

# 定义宏
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += APP_VERSION=\\\"1.0.0\\\"

# MQTT支持说明:
# 本项目使用Qt的QTcpSocket实现巴法云TCP协议，无需额外链接mosquitto库
# 如需使用标准MQTT协议，可添加: LIBS += -L/usr/lib -lmosquittopp -lmosquitto

# 安装路径 (根据平台自动选择)
unix:!android {
    contains(QT_ARCH, arm) {
        # ARM平台(如IMX6ULL开发板)安装到/root
        target.path = /root
    } else {
        # PC平台安装到标准位置
        target.path = /usr/local/bin
    }
    !isEmpty(target.path): INSTALLS += target
}

